<?php namespace App\Admin\Access\User\Services;

use Input;
trait ResetPassword {
    
    public function resetPassword(){
        $passwordInput = Input::get('password', '');
		if(!$passwordInput){
			return $this->inputError();
		}
        $saltcode = $saltcode = rand(10000, 99999);
        $password = md5($passwordInput.$saltcode);
        try {
            $this->repository->resetCriteria()->addCriteria($this->getIndexCriteria());
            $this->repository->update([
                'saltcode' => $saltcode,
                'password' => $password
            ]);
            return $this->success();
		} catch (\Exception $ex) {
            return $this->sysError($ex);
		}
    }
}